CSS Full Course Day 2 [Hindi] 💻 | Selectors & Properties 🚀 | Mohit Decodes
🎨 CSS Tutorial – Day 2: Selectors & Properties
Welcome to Day 2 of the CSS Full Course [Hindi] by Mohit Decodes! Today, we dive deeper into CSS by learning about selectors — how to target HTML elements — and properties that define the styles.
🔹 What are CSS Selectors?
Selectors specify which HTML elements to style. Some common selectors are:
- Element Selector: targets elements by tag name
css
CopyEdit
p { color: blue; }
- Class Selector: targets elements with a specific class
css
CopyEdit
.highlight { background-color: yellow; }
- ID Selector: targets a unique element by id
css
CopyEdit
#header { font-size: 24px; }
- Universal Selector: targets all elements
css
CopyEdit
* { margin: 0; padding: 0; }
🔹 CSS Properties
Properties define what aspect of the element to style. Examples include:
color
— text colorbackground-color
— background colorfont-size
— text sizemargin
— space outside elementpadding
— space inside elementborder
— border style and size
⚙️ Example:
css
CopyEdit
/* Make all paragraphs red with a light yellow background */
p {
color: red;
background-color: #ffffcc;
padding: 10px;
border: 1px solid #ccc;
}
💡 Tips:
- Combine selectors for precision (
div.highlight
) - Use classes for reusable styles
- IDs should be unique per page